<template>
  <div class="select-city container-box">
    <van-nav-bar
      title="选择城市"
      left-arrow
      @click-left="$router.go(-1)"
      @click-right="onClickRight"
    >
      <!-- 个人中心 -->
      <template #right>
        <van-icon name="apps-o" v-if="change" @click="changeFn" />
        <van-icon name="cross" v-else @click="changeFn" /> </template
    ></van-nav-bar>

    <van-grid :class="change ? 'hidden' : 'show'">
      <van-grid-item icon="shop-o" text="首页" />
      <van-grid-item icon="contact" text="个人中心" />
      <van-grid-item icon="cart-o" text="购物车" />
      <van-grid-item icon="coupon-o" text="活动礼券" />
    </van-grid>

    <!-- 当前定位 -->
    <div class="locations"><van-icon name="aim" />武汉市</div>

    <!-- 热门城市 -->
    <div class="city-card hot-city">
      <h3>热门城市</h3>
      <ul>
        <li>上海市</li>
        <li>北京市</li>
        <li>广州市</li>
        <li>深圳市</li>
        <li>杭州市</li>
        <li>南京市</li>
      </ul>
    </div>

    <!-- 所有城市 -->
    <van-index-bar>
      <van-index-anchor index="A" />
      <van-cell title="文本" />
      <van-cell title="文本" />
      <van-cell title="文本" />

      <van-index-anchor index="B" />
      <van-cell title="文本" />
      <van-cell title="文本" />
      <van-cell title="文本" />
    </van-index-bar>
  </div>
</template>

<script>
export default {
  data() {
    return {
      change: true
    }
  },
  methods: {
    onClickRight() {
      console.log('asdas')
    },
    changeFn() {
      this.change = !this.change
    }
  }
}
</script>

<style lang="less" scoped>
/deep/.van-nav-bar i.van-icon,
/deep/.van-nav-bar__text,
/deep/.van-nav-bar__title {
  color: #ff4463;
}

.locations {
  height: 0.82rem;
  padding: 0.2rem 0.4rem;
  font-size: 0.3rem;
  display: flex;
  align-items: center;

  .van-icon {
    margin-right: 0.1rem;
    color: #ff4463;
  }
}

/deep/.van-index-anchor {
  color: #ff4463;
  background-color: #f0f0f0;
}

.city-card {
  h3 {
    font-size: 0.24rem;
    padding: 0.2rem 0.4rem;
    color: #ff4463;
    background-color: #f0f0f0;
  }
}

.hot-city {
  ul {
    display: flex;
    flex-wrap: wrap;
    li {
      width: 50%;
      padding: 0.2rem 0;
      font-size: 0.24rem;
      text-align: center;
      border-bottom: 1px solid #f0f0f0;
      border-right: 1px solid #f0f0f0;
      &:nth-of-type(2n) {
        border-right: none;
      }
    }
  }
}

/deep/.van-index-bar__sidebar {
  span {
    margin: 0.06rem 0;
  }
}

.van-nav-bar {
  /deep/.van-nav-bar__title {
    color: #ff4463;
  }
  .van-icon {
    color: #ff4463;
    font-size: 0.4rem;
  }
}
.container-box {
  background-color: #f5f5f5;
  padding-bottom: 60px;
  .van-nav-bar {
    /deep/.van-nav-bar__title {
      color: #ff4463;
    }
    .van-icon {
      color: #ff4463;
      font-size: 0.4rem;
    }
  }
  .van-grid {
    width: 100%;
    font-size: 0.26rem;
    /deep/.van-grid-item__icon {
      font-size: 0.34rem;
    }
    /deep/span {
      margin-top: 0.05rem;
    }
    /deep/.van-grid-item__content {
      padding: 0.2rem;
    }
  }
  .hidden {
    transition: all 0.5s;
    display: none;
  }
  .show {
    transition: all 0.5s;
    display: flex;
  }
}
</style>
